
<?php
 function getWeekDay($date){
 	switch ($date)
 	{
		case '0' : 
			return 'Sunday';
			break;
		case '1':
			return 'Monday';			
			break;
		case '2':
			return 'Tuesday';
			break;
		case '3':
			return 'Wednesday';
			break;
		case '4':		
			return 'Thursday';
			break;
		case '5':	
			return 'Friday';
			break;
		case '6':
			return 'Saturday';
			break;					
	}
 }
 $worktype= array(
 		"Normal"=>"Normal", 		
 		"Night"=>"Night",
 		"Moon"=>"Moon",
 		"SL"=>"SL",
 		"UL"=>"UL",
 		"PL"=>"PL",
 		"AL"=>"AL",
 		"HLD"=>"HLD"
 		 		
 );
 $bar="WorkDay - ".$name;
 $day=$Date;
 
 ?>



<?php	$atr=array(
					"name"=>"workDay",
					"onload"=>"Caculate()"
				  ); 
	echo form_open('workDay/nhap',$atr);	
?>
	<table id="box-table-a" cellspacing="1" align="right" width="900px" >
		
		<tr id="hi"><td colspan=9 align=right class=bar><?php echo $bar;?></td></tr>
		<tr>
			<td>Staff_ID</td>
			<td>Date</td>			
			<td>StartTime</td>
			<td>EndTime</td>
			<td>WorkTime</td>
			<td>OT</td>
			<td>ON</td>
			<td>WeekDay</td>
			<td>DayType</td>			
		</tr>
	<input type="hidden" name="kc" value="<?php echo $kc ?>" />	
  <?php for ($i=0; $i < $kc ; $i++) {?> 
      	<tr>
      		<?php $t=getWeekDay(date("w", strtotime($day)+$i*86400));?>
      		<td><input  type="text" name="Staff_ID" size="9" value="<?php echo $Staff_ID; ?>"/></td>
      		<td ><input type="text"  size="9"  name="<?php echo "Date".$i; ?>" value="<?php echo date("Y-m-d", strtotime($day)+$i*86400);?>" /> </td>      		
      		<td ><input type="text"  size="9"  id='<?php echo "a".$i ;?>'  name="<?php echo "StartTime".$i; ?>" value="<?php if (isset($TM[$i])) {echo $TM[$i]->StartTime ;} else 
      			if ($t=='Sunday' || $t=='Saturday') {echo "00:00";} else echo "08:00" ; ?>" onchange="calculate(<?php echo $i;  ?>)"  /> </td>
      		<td><input type="text"  size="8"  id='<?php echo "b".$i ;?>'  name="<?php echo"EndTime".$i; ?>" value="<?php if (isset($TM[$i])) {echo $TM[$i]->EndTime ;} else 
      			if ($t=='Sunday' || $t=='Saturday') {echo "00:00";} else echo "17:00" ; ?>" onchange="calculate(<?php echo $i;  ?>)" /></td>
      		<td><input type="text"  size="8" readonly="readonly" id='<?php echo "c".$i ;?>' name="<?php echo "WorkTime".$i; ?>" value="8"  /></td>      		
      		<td><input type="text" size="8"  readonly="readonly" id='<?php echo "d".$i ;?>' name="<?php echo "OT".$i; ?>" value="0"/></td>
      		<td><input type="text" size="8" readonly="readonly" id='<?php echo "e".$i ;?>' name="<?php echo "ON".$i; ?>" value="0" /></td>
      		<td><input type="text" size="8" readonly="readonly" name="<?php echo "WeekDay".$i; ?>" value=" <?php echo $t;?> " /></td>
      		<?php $js='id="f'.$i. '" onChange="OnchangeTime(this.form.DayType'.$i.','.$i.');"'; ?>      		
      		<td><?php if (isset($TM[$i])){echo form_dropdown( "DayType".$i,  $worktype,$TM[$i]->DayType,$js );}else {echo form_dropdown( "DayType".$i,  $worktype,'Normal',$js );} ?> </td>
      	</tr>      
  <?php } ?> 		
		<tr>			
			<td colspan="4" align="left"> <input type="submit"  " value="preview" name="preview"  /> </td>
			<td colspan="5" align="right"> <input type="submit" value="next" name="next"/> </td>			
		</tr>
	</table>
	
<?php form_close(); ?>	